package pl.register.android.program;

import pl.register.android.lesson.LessonProgram;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Mateusz Strzelecki
 * @since 2013-04-09
 */

public class Program implements Serializable {

    private List<LessonProgram> lessons;

    public Program() {
        this.lessons = new ArrayList<LessonProgram>();
    }

    public Program(List<LessonProgram> lessons) {
        this.lessons = lessons;
    }

    public List<LessonProgram> getLessons() {
        return lessons;
    }

    public void setLessons(List<LessonProgram> lessons) {
        this.lessons = lessons;
    }

    public void addLessonProgram(LessonProgram lessonProgram) {
        lessons.add(lessonProgram);
    }

    public void removeLessonProgram(LessonProgram lessonProgram) {
        lessons.remove(lessonProgram);
    }

    public int countProgramLessons() {
        return lessons.size();
    }

    public LessonProgram getProgramLessonBy(int position) {
        if (position >= 0 && position < countProgramLessons()) {
            return lessons.get(position).newReferences();
        }
        return null;
    }

    public LessonProgram getLastLessonProgram() {
        if (lessons.size() > 0) {
            return lessons.get(lessons.size() - 1);
        }
        return null;
    }

    @Override
    public String toString() {
        return "Program{" +
                "lessons=" + lessons +
                '}';
    }
}